#!/usr/bin/env python3
import sys

sys.dont_write_bytecode = True


import netifaces

def get_real_ip():
    interfaces = netifaces.interfaces()
    for interface in interfaces:
        if interface == 'lo':
            continue
        addrs = netifaces.ifaddresses(interface)
        if netifaces.AF_INET in addrs:
            ip_info = addrs[netifaces.AF_INET][0]
            ip = ip_info['addr']
            if not ip.startswith('127.') and interface != 'docker0':
                print(f"网卡: {interface}, IPv4 地址: {ip}")
                return ip
    return None

real_ip = get_real_ip()
print("最真实的 IP 地址:", real_ip)